﻿// Study0502.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
// 第五章 数据的共享和保护 静态成员

#include <iostream>
using namespace std;

class Point
{
public:
	Point(int xx, int yy) :x(xx), y(yy)
	{
		count++;
	}
	Point(const Point& p)
	{
		x = p.GetX();
		y = p.GetY();
		count++;
	};
	~Point()
	{
		count--;
	}
	int GetX() const {
		return x;
	}
	int GetY() const
	{
		return y;
	}
	static void ShowCount()
	{
		cout << "  Object count = " << count << endl;
	}

private:
	int x, y;
	static int count;
};
int Point::count = 0;

int main()
{
	Point::ShowCount();
	Point a(4, 5);
	cout << "Point A: " << a.GetX() << ", " << a.GetY();
	Point::ShowCount();
	Point b(a);
	cout << "Point B: " << b.GetX() << ", " << b.GetY();
	Point::ShowCount();
	return 0;
}

